#ifndef OBJECT_H
#define OBJECT_H

#include "Shader.h"
#include "Model.h"
#include "Material.h"
#include "Constants.h"
#include "Light.h"

#include <GL/glew.h>
#include <GL/gl.h>

#include <glm/glm.hpp>

using glm::mat4;

class Object
{
public:

    // Static variables.
    static vector<Light> lights;
    static mat4 viewMatrix;
    static mat4 projMatrix;
    static double gameTime;
    static GLuint lastVAO;
    static unsigned int lastShader;

    // Functions.
    explicit Object(Shader* shader, Model* model, Material* material);
    ~Object();

    void update(const double timeElapsed);
    void render();

    void setPosition(const vec3& pos);
    void setOrientation(const vec3& ori);
    void setMovement(const vec3& dir);
    void setRotation(const vec3& rot);

    vec3 getPos() const;
    bool isEmissive() const;
    bool isStateOk() const;

private:

    // Disable copying.
    Object(Object const& rhs);
    Object&operator=(Object const& rhs);

    // Functions.
    bool init();
    GLuint loadTexture(const char* path);

    // Variables.
    string m_filename;

    vec3 m_pos;
    vec3 m_ori;
    vec3 m_dir;
    vec3 m_rot;
    bool m_posSet;
    bool m_oriSet;

    GLuint m_texture0;
    GLuint m_texture0normal;
    GLuint m_texture0bump;

    Shader* m_shader;
    Model* m_model;
    Material* m_material;

    GLint m_uniModel;
    GLint m_uniView;
    GLint m_uniModelView;
    GLint m_uniModelViewProj;
    glm::mat4 m_modelMatrix;
    glm::mat4 m_modelViewMatrix;
    glm::mat4 m_modelViewProjMatrix;
    
    bool m_stateOk;
};

#endif // OBJECT_H